package errors

import "encoding/json"

const (
	ErrorArg            =     4001
	ErrorForbidden       =     4003


	ErrorLogin      	=     5001
	ErrorListComment 	=     5002
	ErrorUserNotFound   =     5003
	ErrorAddComment     =     5004

)

var	(
	OK          		= New(0,"")
	ErrListComment		= New(ErrorListComment,"list comment error")          //获取评论列表失败
	ErrArg              = New(ErrorArg,"invalid args")
	ErrForbidden       = New(ErrorForbidden,"not Authorization")

	ErrUserNotFound     = New(ErrorUserNotFound,"user not found")
	ErrAddComment       = New(ErrorAddComment, "add comment error")
	ErrLogin    =		 New(ErrorLogin,"login error")
)


type Error struct {
	Code   int         `json:"code"`
	Msg    string       `json:"msg"`
}

func(e *Error)Error()string{
	eb,_ := json.Marshal(e)
	return string(eb)
}

func New(ErrCode int,msg string)*Error{
	return &Error{
		Code:ErrCode,
		Msg:msg,
	}
}